package com.guitest.gui.sqlutils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Insert {
    public void InsertTest(String username, String password, double tem) {
        Connection conn = null;
        PreparedStatement st= null;

        try {
            conn = JdbcUtils.getConnection();
            String sql = "insert into user(`username`, `password`, `wendu`) values(?,?,?)";

            st = conn.prepareStatement(sql);

            st.setString(1,username);
            st.setString(2,password);
            st.setDouble(3,tem);

            int i = st.executeUpdate();
            if (i > 0){
                System.out.println("插入成功");
            }

        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JdbcUtils.release(conn,st,null);
        }
    }
}
